﻿using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using FreeGoo.GameEngine.Renderables;
using FreeGoo.WpfRenderer.Constants;

#if SILVERLIGHT
//using Brushes=System.Windows.Media.Brush;
#else
using Brushes = System.Windows.Media.Brushes;
#endif

namespace FreeGoo.WpfRenderer
{
    public class PolylineRenderer : RendererWithCanvas
    {
        public PolylineRenderer(RendererFactory factory, BodyRenderable bodyRenderable, bool addReturnStroke)
            : base(factory, bodyRenderable)
        {
            Polyline = RendererFactory.CreatePolylineFromGeom(bodyRenderable.Geom);
            if (addReturnStroke)
            {
                Polyline.Points.Add(new Point(0, 0));
            }

            if (bodyRenderable.IsDeadly)
            {
                Polyline.Fill = BrushConstants.Red;
            }

            SetCanvasContent(Polyline);        
        }

        public Polyline Polyline { get; set; }

        public override void Delete()
        {
            Factory.Canvas.Children.Remove(Canvas);
        }

        public override void StateChanged()
        {
        }
    }
}
